import 'dart:convert';

//配置射频高低频频率时的参数
class AntennaData {
  int antennaNo;
  int powerValue;
  AntennaData({
    required this.antennaNo,
    required this.powerValue,
  });

  static List<AntennaData> antennaList = <AntennaData>[
    AntennaData(antennaNo: 1, powerValue: 1000,),
    AntennaData(antennaNo: 2, powerValue: 1000, ),
    AntennaData(antennaNo: 3, powerValue: 1000, ),
    AntennaData(antennaNo: 4, powerValue: 1000, ),
    AntennaData(antennaNo: 5, powerValue: 1000, ),
  ];

  AntennaData copyWith({
    int? antennaNo,
    int? powerValue,
  }) {
    return AntennaData(
      antennaNo: antennaNo ?? this.antennaNo,
      powerValue: powerValue ?? this.powerValue,
    );
  }

  Map<String, dynamic> toMap() {
    return {
      'antennaNo': antennaNo,
      'powerValue': powerValue,
    };
  }

  factory AntennaData.fromMap(Map<String, dynamic> map) {
    return AntennaData(
      antennaNo: map['antennaNo']?.toInt() ?? 0,
      powerValue: map['powerValue']?.toInt() ?? 0,
    );
  }

  String toJson() => json.encode(toMap());

  factory AntennaData.fromJson(String source) =>
      AntennaData.fromMap(json.decode(source));

  @override
  String toString() =>
      'AntennaData(antennaNo: $antennaNo, powerValue: $powerValue)';

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) return true;

    return other is AntennaData &&
        other.antennaNo == antennaNo &&
        other.powerValue == powerValue ;
  }

  @override
  int get hashCode =>
      antennaNo.hashCode ^ powerValue.hashCode;
}
